package com.xfz.Controller;

import com.xfz.User.Material;
import com.xfz.User.Supplier;
import com.xfz.common.Res;
import com.xfz.service.MaterialService;
import com.xfz.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/material")
public class MaterialController {
    @Autowired
    MaterialService materialService;
    //查询商家
    @GetMapping("/materials")
    public Res getmaterial() {
        List<Material> material = materialService.findAllMaterials();
        if(material!=null){
            return new Res(1, "成功", material);
        } else {
            return new Res(0, "失败");
        }

    }
    @PostMapping("/addmaterials")
    public Res addmaterials(@RequestBody Material material) {
        List<Material> materialing = materialService.saveMaterial(material);
        if(material!=null){
            return new Res(1, "成功", materialing);
        } else {
            return new Res(0, "失败");
        }

    }

}
